package com.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/ribbon")
public class RibbonController {

    private final Logger logger = LoggerFactory.getLogger(RibbonController.class);
    @Autowired
    Environment environment;

    @RequestMapping(value = "/hello")
    public String hello() throws InterruptedException {
        logger.info("=========当前端口号:{}=========", getPort());
        Thread.sleep(5000);
        return "ribbon hello world , 端口号:" + getPort();
    }

    private String getPort(){
        return environment.getProperty("local.server.port");
    }
}
